#include<bits/stdc++.h>
using namespace std;

int n, k, ans;
int a[100], vis[100];

bool check(int x){
	if(x <= 1){
		return false;
	}
	int k = sqrt(x);
	for(int i = 2;i <= k;i++){
		if(x%i == 0){
			return false;
		}
	}
	return true;
}

void dfs(int num, int sum, int preIdx){
	if(num == k && check(sum)){
		ans++;
		return ;
	}
	for(int i = preIdx+1;i <= n;i++){
		if(vis[i]){
			continue;
		}
		sum += a[i];
		vis[i] = 1;
		dfs(num+1, sum, i);
		sum -= a[i];
		vis[i] = 0;
	}
}

int main(){
	cin>>n>>k;
	for(int i = 1;i <= n;i++){
		cin>>a[i];
	}
	dfs(0, 0, 0);
	cout<<ans;
	return 0;
}
